package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.admission.dao.AttentionDao;
import com.admission.model.Attention;

@Repository
@Transactional
public class AttentionManager {
	private AttentionDao attentionDao;
	
	@Transactional(readOnly = true)
	public Page<Attention> pageAttention(final Page<Attention> page, final List<PropertyFilter> filters){
		return attentionDao.findPage(page, filters);
	}

	public void save(Attention entity){
		attentionDao.save(entity);
	}
	
	public void saveList(List<Attention> list){
		Attention atte = null;
		for(int i = 0; i < list.size(); i++){
			atte = new Attention();
			atte = list.get(i);
			this.save(atte);
		}
	}
	
	public void delete(Attention entity){
		attentionDao.delete(entity);
	}
	
	public List<Attention> list(){
		return attentionDao.getAll();
	}
	
	public void clear(){
		List<Attention> list = this.list();
		for(int i = 0; i < list.size(); i++){
			this.delete(list.get(i));
		}
	}
	
	public Attention getById(String id){
		return attentionDao.get(id);
	}
	
	@Autowired
	public void setAttentionDao(AttentionDao attentionDao) {
		this.attentionDao = attentionDao;
	}
}
